package edu.unicen.compilers.actions;


import java.text.DecimalFormat;
import java.util.ArrayList;

import edu.unicen.compilers.lexicon.LexicalAnalyzer;
import edu.unicen.compilers.parser.Parser;
import edu.unicen.compilers.parser.ParserVal;


public final class SemanticAction4 extends SemanticAction{
	
	
	

	public SemanticAction4(LexicalAnalyzer la, Parser parser) {
		super(la, parser);
	}

	@Override
	public void execute() {
		String token=this.la.getPartialLexeme();		
		Double number= Double.valueOf(token);
		ArrayList<String> v=new ArrayList<String>();
		if(number > Math.pow(2, 31)){
			//System.out.print("Error: el numero "+number+" fuera de rango, ignorado");
			this.la.setLastConstant(token);
			la.setToken(DIGITOSERROR);
			return ;
		}
		v.add("CONST");
		DecimalFormat df = new DecimalFormat("#########");
		la.putSymbol(df.format(number),v);
		la.setLexeme(df.format(number));
		la.setLastVal(df.format(number));
		la.setToken(DIGITOS);
		parser.setYylval(new ParserVal(df.format(number)));
	}
		
}
